import React from 'react';
import ReactDOM from 'react-dom';
import mirror, { connect, actions } from 'mirrorx';
import { Carousel, WhiteSpace, WingBlank, List } from 'antd-mobile';

const Item = List.Item;
const Brief = Item.Brief;


class App extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            productList: []
        }
      
    }

    componentDidMount() {
        this.requestFusionList();

        T.loginAction();
    }

    requestFusionList =()=>{
       T.fetchFusion({
        url:'/promotion/queryChannelGoodsList',
        data:{
          "partnerId":1005012,
           pageIndex:1,
           pageSize:1         
        }
      }).then((res)=>{        
        if(res.value){
          this.setState({          
            productList:res.value.resultList || []
          })
        }     
      })
      // var p2 = T.fetchFusion({
      //   url:'/promotion/queryChannelGoodsList',
      //   data:{
      //     "partnerId":1005013,
      //      pageIndex:1,
      //      pageSize:1         
      //   }
      // }).then((res)=>{        
      //   if(res.value){
      //     return res.value.resultList[0] || {}
      //   }     
      // })     
      // Promise.all([p1, p2]).then(values => { 
      //   console.log(values);
      //   this.setState({          
      //     productList:values || []
      //   })
      // })      
    }    

    toProductDetail=(id,name,channelGoodId)=>{  //跳转到相应的商品详情页
      actions.routing.push({
        pathname:'/product-detail-poc',
        search:'?goodId=' + id +"&productName=" + name +"&channelGoodId=" + channelGoodId
      }) 
  }

    render() {
        const {productList} = this.state;  
        return (<div className="main product-list bor-top" id="grab-list">
            <div className="topBg"></div> 
            <div className="list">
            {productList && productList.map((item,index)=>
              <div className="item" key={index} onClick={()=>this.toProductDetail(item.marketGoodsId,item.channelGoodsName,item.id)}>
              <div className="f28 fc0 strong name">{item.channelGoodsName}</div>
              <p className="text f26 lh20">{item.channelGoodsDesc}</p>             
            </div>
            )}
            </div>
          </div>)           
    }
  }

export default App;   